<%@page import="java.util.TreeMap"%>
<%@page import="java.util.Map"%>
<%@page import="entities.MetaSeo"%>
<%@page import="systems.AdsSystem"%>
<%@page import="helpers.StringHelper"%>
<%@page import="helpers.UrlHelper"%>
<%@page import="java.util.List"%>
<%@page import="entities.IpAddress"%>
<%
String error = (String) request.getAttribute("error");
IpAddress ipAddress = (IpAddress) request.getAttribute("ipAddress");
MetaSeo metaseo = (MetaSeo) request.getAttribute("metaseo");

//Set content for Seo
Map<String, String> replates = new TreeMap<String, String>();
replates.put("__SERVER_NAME__", UrlHelper.getDomainServer(request));
replates.put("__SERVER_URL__", UrlHelper.getServerUrl(request));

String title = StringHelper.replateContent(metaseo.getTitle(), replates);
String description = StringHelper.replateContent(metaseo.getDescription(), replates);
String keywords = StringHelper.replateContent(metaseo.getKeywords(), replates);
String url = StringHelper.replateContent(metaseo.getOgurl(), replates);

if (ipAddress != null) {
	replates.put("__IP_ADDRESS__", ipAddress.getIp());
	replates.put("__COUNTRY_NAME__", ipAddress.getCountryName());
	replates.put("__CITY_NAME__", ipAddress.getCity());
	replates.put("__IP_LIST_DOMAIN__", StringHelper.listToString(ipAddress.getDomains(), ", ", 6));
	
	title = StringHelper.replateContent(metaseo.getTitleInfo(), replates);
	description = StringHelper.replateContent(metaseo.getDescriptionInfo(), replates);
	keywords = StringHelper.replateContent(metaseo.getKeywordsInfo(), replates);
	url = StringHelper.replateContent(metaseo.getOgurlInfo(), replates);
}
%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<jsp:include page="/templates/showdomain/layouts/header.jsp">
	<jsp:param name="title" value="<%=title %>" />
    <jsp:param name="description" value="<%=description %>" />
    <jsp:param name="keywords" value="<%=keywords %>" />
    <jsp:param name="ogtitle" value="<%=title %>" />
    <jsp:param name="ogurl" value="<%=url %>" />
    <jsp:param name="ogdescription" value="<%=description%>" />
</jsp:include>

	<script type="text/javascript" src="/templates/showdomain/js/reverseip.js"></script>
	
	<div id="content">
		<jsp:include page="/templates/showdomain/elements/search_bar.jsp" />
		
		<div class="row">
			<!-- Left Content BEGIN -->
			<div class="span9">
				<section class="check-page">
					<div class="box1 block">
						<h3 class="title">Reverse Ip</h3>
						<div class="row-fluid border-space">
							<div class="span6 search-bar2">
								<div class="item-stream unstyled search-input-stream">
									<div class="stream-item stream-header search-input-item">
										<form class="form-inline search-form" action="/reverseip">
											<input type="text" value="" placeholder="ex: 172.168.192.5" name="q" id="artist_search" class="xlarge ui-autocomplete-input" role="textbox">
					          				<button type="submit" id="artist_submit" class="btn btn-large btn-inverse"><i class="icon-search icon-white"></i></button>
										</form>
									</div>
								</div>
							</div>
						</div>

						<div class="result">
							<br />
							<div class="adv">
								<%=AdsSystem.getAds468x60() %>
							</div>
							<% if (error != null) { %>
								<%=error %>
							<% } %>
							<% if (ipAddress != null) { %>
							<section class="ip-result">
								<div class="block">
									<h3 class="title">Ip <%=ipAddress.getIp() %> Info</h3>
									<div class="adv left">
										<%=AdsSystem.getAds468x15() %>
									</div>
									<div class="content-block">
										<div class="row-fluid">
											<div class="span6">
												<dl class="dl-horizontal clearfix">
													<dt>Country Code:</dt>
													<dd><%=ipAddress.getCountryCode() %></dd>
													<dt>Country Code3:</dt>
													<dd><%=ipAddress.getCountryCode3() %></dd>
													<dt>Country Name:</dt>
													<dd>
														<%=ipAddress.getCountryName() %>
													</dd>
													<dt>City:</dt>
													<dd><%=ipAddress.getCity() %></dd>
													<dt>Continent Code:</dt>
													<dd><%=ipAddress.getContinentCode() %></dd>
													<dt>Latitude:</dt>
													<dd><%=ipAddress.getLatitude() %></dd>
													<dt>Longitude:</dt>
													<dd><%=ipAddress.getLongitude() %></dd>
												</dl>
											</div>
											<div class="span6">
												<img src="http://maps.google.com/maps/api/staticmap?sensor=false&size=300x300&markers=size:mid|color:blue|label:1|<%=ipAddress.getLatitude() %>,<%=ipAddress.getLongitude() %>&markers=color:black|label:0|<%=ipAddress.getLatitude() %>,<%=ipAddress.getLongitude() %>">
											</div>
										</div>
										<br />
										<div class="row-fluid f-info">
											<div class="span12">
												<div class="adv">
													<%=AdsSystem.getAds468x60() %>
												</div>
												<h4>Site same <%=ipAddress.getIp() %> Info</h4>
												<ul>
													<%
													List<String> domains = ipAddress.getDomains();
													for (int i = 0; i < domains.size(); i++) {
													%>
													<li>
														<a href="/d/<%=domains.get(i)%>"><%=domains.get(i)%></a>
													</li>
													<% } %>
												</ul>
											</div>
										</div>
									</div>
								</div>
								
							</section>
							<% } %>
						</div>
					</div>
				</section>
			</div>
			<!-- Left Content END -->
			
			<jsp:include page="/templates/showdomain/elements/right.jsp" />
		</div>
		
		
	</div>
		
<jsp:include page="/templates/showdomain/layouts/footer.jsp" />